//()abd
// 输入一个字符串, 输出一个字符串, 小括号中的字符是等效的
const readline = require("readline");
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
let initStr;
rl.on("line", (line) => {
    if (initStr === undefined) {
        initStr = line.trim().replaceAll(/\s+/g, "").split("")
        console.log(getResult(initStr))
        // clear
        initStr = undefined
    }

})

function getResult(initStr) {
    // 先过滤, 把() 内容放一组, 非() 放一组
    let equalArr = [] // 放()内容
    let resArr = [] // 剔除来的内容

    let stack = []
    let flag = false
    for (let i = 0; i < initStr.length; i++) {
        let char = initStr[i]
        if (char === "(") {
            flag = true
        } else if (char === ")") {
            flag = false
            if (stack.length) equalArr.push([...stack])
            stack.length = 0
        } else {
            if (flag) {
                stack.push(char)
            } else {
                resArr.push(char)
            }
        }
    }

    // 处理() 内容, 做等效, 最后做成一个map
    //小写和大写之间的差距?
    let mapArr = []
    let diff = Math.abs(("A".charCodeAt(0) - "a".charCodeAt(0)))
    if(equalArr[0]) mapArr = [...equalArr[0]]
    for (let i = 1; i < equalArr.length; i++) {
        let arr = equalArr[i]
        for (let charB of arr) {
            // 判断合并条件
            let charC = charB
            if (charB <= "Z") { // 大写
                charC = String.fromCharCode(charB.charCodeAt(0) + diff)
            } else { // 小写
                charC = String.fromCharCode(charB.charCodeAt(0) - diff)
            }
            if(mapArr.indexOf(charB) !== -1 || mapArr.indexOf(charC) !== -1) {
                mapArr = mapArr.concat(arr)
                mapArr = Array.from(new Set(mapArr))
                break
            }
        }
    }
    mapArr.sort()
    let map = {}
    for (const char of mapArr) {
        map[char] = mapArr[0]
    }

    // 处理非()内容,找对应, 最后在join 输出
    let ans = resArr.map((char, index) => map[char] || char)
    return ans.length ? ans.join("") : "0"
}